home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / T U R B O Language / Turbo C Tools v6.0 / INCLUDE / BINTRUPT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  6.9 KB  |  176 lines

  1. /**
  2. *
  3. *  BINTRUPT.H    Header file for Turbo C TOOLS Interrupt Service Functions
  4. *
  5. *  Version 6.00  (C)Copyright Blaise Computing Inc.  1986,1987,1989
  6. *
  7. **/
  8.  
  9. #ifndef DEF_BINTRUPT              /* Prevent redefinition.          */
  10. #define DEF_BINTRUPT     1
  11.  
  12. #include <stdlib.h>              /* For size_t.              */
  13. #include <butil.h>              /* For ALLREG.              */
  14. #include <bmem.h>              /* For mmsize().              */
  15.  
  16. typedef struct                  /* ISRMSG:  structure for       */
  17. {                      /* passing messages between ISR */
  18.                       /* and the dispatcher.          */
  19.                       /*                  */
  20.     int      exit_style;          /* Exit style:  see possible    */
  21.                       /* values below.              */
  22.                       /*                  */
  23.     unsigned working_flags;          /* Working value of flags       */
  24.                       /* register.  This will be      */
  25.                       /* be propagated to an ISR's    */
  26.                       /* caller if the ISR returns    */
  27.                       /* without doing an IRET.       */
  28. } ISRMSG;                  /*                  */
  29.  
  30.                       /* Exit styles from an ISR:     */
  31.                       /*                  */
  32. #define IEXIT_NORMAL    0          /* Normal:  return to caller    */
  33.                       /* via IRET              */
  34.                       /*                  */
  35. #define IEXIT_RETF    1          /* Special:  return via far     */
  36.                       /* RETurn               */
  37.  
  38. #define ISRCTRL   struct isr_control  /* ISRCTRL:  ISR control block  */
  39. struct isr_control              /*                  */
  40. {                      /*                  */
  41.     unsigned fcall_opcode;          /* NOP + Far call opcode          */
  42.                       /*  (0x9A90)              */
  43.     void (far *isrdisp)();          /* Address of ISR dispatcher    */
  44.     unsigned iret_opcode;          /* IRET + RETF opcodes (0xcbcf) */
  45.                       /*                  */
  46.     char far *isrstk;              /* Beginning of space allocated */
  47.                       /*  for ISR stack(s).          */
  48.     unsigned isrstksize;          /* ISR stack size           */
  49.     unsigned isrsp;              /* ISR stack pointer value at   */
  50.                       /*  start of current ISR call   */
  51.                       /*                  */
  52.     unsigned isrds;              /* DS value required by ISR     */
  53.     unsigned isres;              /* ES value required by ISR     */
  54.     void (far *isr)(ALLREG *,          /* Address of ISR itself          */
  55.             ISRCTRL *,          /*                  */
  56.             ISRMSG *);          /*                  */
  57.     unsigned isrpsp;              /* PSP of program containing ISR*/
  58.                       /*                  */
  59.     void far *prev_vec;           /* Previous value of vector     */
  60.                       /*                  */
  61.     unsigned level;              /* Number of calls in progress  */
  62.                       /*  (0 if not in use)          */
  63.     unsigned limit;              /* Maximum number of nested     */
  64.                       /*  calls               */
  65.     unsigned signature;           /* Signature identifying this   */
  66.                       /*  structure              */
  67.     unsigned sign2;              /* One's complement of          */
  68.                       /*  "signature"                 */
  69.     char     ident[16];           /* Identifying name          */
  70.     unsigned control;              /* Bit fields to control          */
  71.                       /*  dispatcher options          */
  72.     unsigned status;              /* Status info left by          */
  73.                       /*  dispatcher              */
  74.     char     scratch[10];          /* Scratch space for use by     */
  75.                       /*  dispatcher & related          */
  76.                       /*  programs              */
  77. };
  78.  
  79.     /* Offsets of various items in an ISRCTRL structure.          */
  80.  
  81. #define ICB_ENTRY_OFFSET    0          /* Address to install in          */
  82.                       /* interrupt vector.          */
  83. #define ICB_PSP_OFFSET       24
  84. #define ICB_PREV_OFFSET    26
  85. #define ICB_SGN_OFFSET       34
  86. #define ICB_S2_OFFSET       36
  87. #define ICB_IDENT_OFFSET   38
  88.  
  89.     /* Control bits in ISRCTRL structure.                  */
  90.  
  91. #define ICB_NOCHECK        1          /* Don't adjust stack limit.    */
  92.  
  93. #define ICB_SIGNATURE    (('0' << 8) | 'B')  /* "B0"                   */
  94.  
  95. typedef struct                  /* DEV_HEADER:  Device header   */
  96. {                      /* structure available to       */
  97.                       /* DOS critical error (INT 0x24)*/
  98.                       /* handlers.              */
  99.                       /*                  */
  100.     void far *next_dev;           /* Physical address of next     */
  101.                       /* device header in chain       */
  102.                       /* (0xffff:0xffff if end)       */
  103.                       /*                  */
  104.     unsigned attr;              /* Attribute bits           */
  105.                       /*                  */
  106.     unsigned strategy;              /* Offset of "strategy" routine */
  107.                       /*                  */
  108.     unsigned service;              /* Offset of service routine    */
  109.                       /*                  */
  110.     char     name[8];              /* If character device, this is */
  111.                       /* its name; if block device,   */
  112.                       /* name[0] is the number of     */
  113.                       /* drives served by this driver.*/
  114. } DEV_HEADER;
  115.  
  116.     /* Symbols for use with ISCURPRC                      */
  117.  
  118. #define  IS_SETPROC  1          /* Set currently executing process.     */
  119. #define  IS_RETPROC  0          /* Return currently executing process.  */
  120.  
  121.     /* Error codes.                              */
  122.  
  123. #define  IS_OK          0   /* No error detected.              */
  124. #define  IS_NO_MEMORY      1   /* Insufficient memory.              */
  125. #define  IS_RANGE      2   /* Value out of range.              */
  126.  
  127.     /* Floating point interrupt vectors used by math library          */
  128.  
  129. #define  IS_1ST_FLOAT_VEC    0x34
  130. #define  IS_LAST_FLOAT_VEC   0x3e
  131. #define  IS_NUM_FLOAT_VECS  ((IS_LAST_FLOAT_VEC) - (IS_1ST_FLOAT_VEC) + 1)
  132.  
  133.     /* TURBO C TOOLS functions implemented as macros              */
  134.  
  135. #define isgetvec(intype)  ((void far *) getvect(intype))
  136.  
  137. #define isputvec(intype,ptr) (setvect((intype),(void interrupt (*)())(ptr)))
  138.  
  139. #define isresext(excode)  (keep((excode),mmsize()))
  140.  
  141.     /* Function declarations                          */
  142.  
  143. int cdecl iscall(void far *,ALLREG *);/* Simulate software interrupt  */
  144.                       /*                  */
  145.                       /* Install a Turbo C TOOLS      */
  146. int cdecl isinstal(int,           /* interrupt service routine    */
  147.            void (*)(ALLREG *,ISRCTRL *,ISRMSG *),
  148.            const char *,      /*                  */
  149.            ISRCTRL *,          /*                  */
  150.            char *,          /*                  */
  151.            int,           /*                  */
  152.            int);          /*                  */
  153.                       /*                  */
  154.                       /* Prepare ISR control block    */
  155. void cdecl isprep(void (*)(ALLREG *,ISRCTRL *,ISRMSG *),
  156.           const char *,       /*                  */
  157.           ISRCTRL *,          /*                  */
  158.           char *,          /*                  */
  159.           int,              /*                  */
  160.           int);           /*                  */
  161.                       /*                  */
  162. ISRCTRL far * cdecl issense(          /* Detect presence of Turbo C   */
  163.         void far *,const char *); /* TOOLS or C TOOLS PLUS or     */
  164.                       /* LIGHT TOOLS interrupt          */
  165.                       /* service routine          */
  166.                       /*                  */
  167. int cdecl isremove(unsigned);          /* Remove resident program      */
  168.                       /*                  */
  169. unsigned cdecl iscurprc(int,unsigned);/* Return or set PSP of          */
  170.                       /* currently executing process. */
  171.                       /*                  */
  172. int cdecl isreserv(size_t,size_t,     /* Allocate block; also reserve */
  173.            char **);          /* space for malloc() from ISR. */
  174.  
  175. #endif                      /* Ends "#ifndef DEF_BINTRUPT"  */
  176.